import { allowEditMenu } from './data';
import { query, table } from '../data/data';
import { queueUpgradeList } from '@/api/modules/esl/upgrade';
import { resetForm } from './form';

export const create = () => {
  allowEditMenu.value = true;
  resetForm();
};
export const list = async () => {
  table.value.loading = true;
  const { data } = await queueUpgradeList(query.value);
  table.value.data = data.rows;
  table.value.loading = false;
};

export const edit = (id?: string) => {
  const ids = id ? [id] : table.value.keys;
  allowEditMenu.value = true;
  table.value.loading = false;
};

export const remove = async (id?: string) => {
  const ids = id ? [id] : table.value.keys;
  await list();
};

export const detail = () => {
  allowEditMenu.value = true;
  table.value.loading = false;
};
export const search = () => {
  query.value.pageNum = 1;
  list();
};
